{% extends 'base.html' %}
{% block css-content %}
    <link rel="stylesheet" href="/static/jquery-confirm/jquery-confirm.min.css">
    <link rel="stylesheet" href="/static/css/bootstrap-select.css">
	<style type="text/css">
		pre {
			overflow: auto;
			white-space: normal;
			white-space: pre-wrap; /* css-3 */
			white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
			white-space: -pre-wrap; /* Opera 4-6 */
			white-space: -o-pre-wrap; /* Opera 7 */
			word-wrap: break-word; /* Internet Explorer 5.5+ */
			font-family: Consolas, monospace;
			color: #ADFF2F;
			background-color: #000000;
		}
	  .dropdown-menu {
			max-height: 500px;
			overflow-y: auto;
			overflow-x: hidden;
		} 
	</style>   
{% endblock %}
{% block page-content %}
        <div class="clearfix"></div> 
        
		<div class="row">
              <div class="col-md-5 col-xs-12">

                <div class="x_panel">
                  <div class="x_title">
                    <h2>模块工具 <small>Deploy model</small></h2>
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                      </li>
                      <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                      </li>
                    </ul>
                    <div class="clearfix"></div>
                  </div>

                  <div class="x_content">
                     <form role="form" id="deployModelRun" data-parsley-validate class="form-horizontal form-label-left">{% csrf_token %}
						<fieldset>						
							<div class="form-group" >			 		             
									<label class="col-sm-2 control-label">选择方式</label>
									<div class="col-sm-6">
										<select class="selectpicker form-control" name="server_model" id="server_model">
											<option value="" name="server_model" disabled selected="selected">选择一个类型</option>
											<option value="business" name="server_model">业务项目</option>
											<option value="inventory_groups" name="server_model">主机组</option>
											<option value="group" name="server_model">使用部门</option>
											<option value="tags" name="server_model">资产标签</option>
											<option value="custom" name="server_model">自定义</option> 	
										</select>		
									</div>	
							</div>	
							<div id='project_server'  style="display:none;">
								<div class="form-group">
									 <label class="col-sm-2 control-label" >业务项目</label>
									 <div class="col-sm-6">
                                           <select class="selectpicker form-control" name="business"  id="deploy_business" onchange="javascript:oBtProjectSelect(this);" required>
                                           	<option name="project" value="" selected="selected">请选择一个项目</option>
                                           </select>
									 </div>
								</div>										
							</div>		
							<div id='inventory_server'  style="display:none;">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label" >动态资产组<i class="fa fa-info-circle" data-toggle="tooltip"  title="根据动态资产添加选择服务器"></i></label>
                                    <div class="col-sm-6">
	                                 <select class="selectpicker form-control" name="inventory" onchange="javascript:oBtInventorySelect(this);">
	                                 </select>
                              		</div>                            		
                                </div> 
								<div class="form-group">
									 <label class="col-sm-2 control-label" >主机组</label>
									 <div class="col-sm-6">
                                           <select class="selectpicker form-control" name="inventory_groups"   onchange="javascript:AssetsTypeSelect(this,'inventory_group');" required>
											<option name="inventory_groups" value="" disabled selected="selected">请选择一个主机组</option>
                                           </select>
									 </div>
								</div>                                  
                            </div>																				
							<div id="group_server" class="form-group" style="display:none;">
								 <label class="col-sm-2 control-label" >使用部门</label>
								 <div class="col-sm-6">
                                       <select class="selectpicker form-control" name="group"  onchange="javascript:AssetsTypeSelect(this,'group');" required> 
                                       </select>
								 </div>
							</div>	
							<div id="tags_server" class="form-group" style="display:none;">
								 <label class="col-sm-2 control-label" >资产标签</label>
								 <div class="col-sm-6">
                                       <select class="selectpicker form-control" name="tags"  onchange="javascript:AssetsTypeSelect(this,'tags');" required> 
                                       </select>
								 </div>
							</div>																																											
							<div id="custom_server" class="form-group" style="display:none;">
								 <label class="col-sm-2 control-label" >服务器</label>
								 <div class="col-sm-6">
                                    <select multiple class="selectpicker form-control"  data-size="10" data-selected-text-format="count > 5" data-live-search="true" data-width="100%"   autocomplete="off"  class="form-control"   autocomplete="off" name="custom"  id="deploy_server" required>
                                    </select>
								 </div>
							</div>							
                                  <input  type="hidden"   class="form-control"  name="model" value="model">
                                  <input  type="hidden"   class="form-control" id="ans_uuid" name="ans_uuid" value="{{assets.uuid}}">											
							<div class="form-group" >			 		             
									<label class="col-sm-2 control-label">模块类型</label>	
									<div class="col-sm-6">
										<select class="form-control" name="deploy_model" id="deploy_model">
											<option value="ping" name="deploy_model">ping</option>	
											<option value="shell" name="deploy_model">shell</option> 	
											<option value="command" name="deploy_model">command</option>
											<option value="yum" name="deploy_model">yum</option> 	
											<option value="copy" name="deploy_model">copy</option> 	
											<option value="service" name="deploy_model">service</option>
											<option value="file" name="deploy_model">file</option>	
											<option value="user" name="deploy_model">user</option>	
											<option value="synchronize" name="deploy_model">sync</option>
											<option value="cron" name="deploy_model">cron</option> 	
											<option value="get_url" name="deploy_model">wget</option>
											<option value="custom" name="deploy_model">自定义</option>
										</select>		
									</div>	
							</div>			
							<div id="custom_model" class="form-group" style="display:none;">
								 <label class="col-sm-2 control-label">自定义模块</label>
								 <div class="col-sm-6">											
									<input type="text"   class="form-control" placeholder="输入模块" name="custom_model" value="">
								</div>
							</div> 											
							</fieldset>																																																					
							<div class="form-group">
								 <label class="col-sm-2 control-label">模块参数</label>
								 <div class="col-sm-6">											
									<input id="deploy_args" type="text"   class="form-control" placeholder="输入模块参数" name="deploy_args" value="">
								</div>
							</div> 	
							<div class="form-group">
								 <label class="col-sm-2 control-label">Debug</label>
								 <div class="col-sm-6">										
										<select class="form-control" name="deploy_debug">
											<option value="off">关闭</option>	
											<option value="on">开启</option> 	
										</select>
								</div>
							</div> 																					
							</fieldset>
							<legend></legend>
							<div class="form-group">
								<label class="col-sm-4 control-label"></label>
								<button type="reset"  class="btn btn-default btn-sm" >重置</button>
								{% if perms.deploy.deploy_exec_deploy_script %}
						 			<button type="button"  class="btn btn-default btn-sm" id="run_deploy_model">执行</button>
						 		{% else %}
						 			<button type="button"  class="btn btn-default btn-sm"  disabled>执行</button>
						 		{% endif %}
					 		</div>									 		
						</form> 
                  </div>
                </div>
              </div>

              <div class="col-md-7 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>执行结果 <small>Results of execution</small></h2>
                    <ul class="nav navbar-right panel_toolbox">
                      <li>
						<a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                      </li>
                      <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                      </li>
                    </ul>
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">
					<pre class="html">
                        <div id="result">
                        </div>
                    </pre>                     
                  </div>
                </div>
              </div>
        </div>
<div style="visibility:hidden">
	<a id="scrollToTop"></a>
</div>
{% endblock %}

{% block js-content %}
	<script src="/static/jquery-confirm/jquery-confirm.min.js"></script>
	<script src="/static/js/deploy/deploy.js"></script>
	<script src="/static/validator/validator.js"></script>
{% endblock %}
